//
//  ReversiVirtualPlayers.m
//  Reversi
//
//  Created by 成瀬 龍人 on 2/10/10.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//

#import "ReversiVirtualPlayers.h"
#import "ReversiPlaying.h"
#import "ReversiPlayer.h"

@implementation ReversiVirtualPlayers
- (void)loadPlugIns{
	players = [[NSMutableArray alloc] init];
	[players addObject:[[ReversiPlayer alloc] initWithBundle:[NSBundle mainBundle]]];
	NSArray* paths = [NSBundle pathsForResourcesOfType:@"bundle" inDirectory:[[NSBundle mainBundle] builtInPlugInsPath]];
	for(NSString* path in paths){
		NSBundle* bundle = [NSBundle bundleWithPath:path];
		id<ReversiPlaying> player = [[bundle principalClass] alloc];
		[players addObject:[player initWithBundle:bundle]];
		NSLog(@"load %@", path);
	}
}

- (id)playerObjectAtIndex:(int)index{
	return [players objectAtIndex:index];
}

- (NSString*)descriptionAtIndex:(int)index{
	return [[players objectAtIndex:index] description];
}

- (int)numberOfItemsInComboBox:(NSComboBox*)aComboBox{
	return [players count];
}

- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index{
	return [[players objectAtIndex:index] name];
}

@end
